﻿/***************************************************************************
//* Foxit Software Inc.
//* Copyright(C) 2005-2014, all rights reserved.
//*
//* The following code is copyrighted and contains proprietary information
//* and trade secrets of Foxit Software Inc.                                                      *
***************************************************************************/

/**
* 简单的Point类
*/
define(function (require, exports, module) {
    var WebPDF = require('../WebPDF.js');
    /**
     * @description Creates a new PDFPoint with an x and y coordinate.
     * @class A utility class that represents a point with an x and y coordinate.
     * @constructor
     * @param {Number} x the x-coordinate
 	 * @param {Number} y the y-coordinate
     * @return an new PDFPoint object.
     * @memberOf WebPDF
     */
    WebPDF.PDFPoint = function (x, y) {
        this.x = this.y = 0;
        if (arguments.length === 2) {
            this.x = isNaN(x) ? 0 : x;
            this.y = isNaN(y) ? 0 : y;
        }

        /**
         * @description Clone a new PDFPoint object from this object.
         * @return {WebPDF.PDFPoint} An new PDFPoint object.
         */
        this.clone = function () {
            return (new this.constructor(this.x, this.y));
        };
        /**
         * @description Set value of this point.
         * @param {Number} x the x-coordinate.
 		* @param {Number} y the y-coordinate.
         */
        this.setPoint = function (x, y) {
            if (isNaN(x) || isNaN(y)) return;
            this.x = x;
            this.y = y;
        };
        /**
         * @description Offset this point.
         * @param {Number} x The x-coordinate to offset.
 		* @param {Number} y The y-coordinate to offset.
         */
        this.offset = function (x, y) {
            if (isNaN(x) || isNaN(y)) return;
            this.x += x;
            this.y += y;
        };
        /**
         * @description Check whether this point is equal to another.
         * @param {WebPDF.PDFPoint} otherPoint Another PDFPoint object.
         */
        this.equal = function (otherPoint) {
            return (this.x === otherPoint.x) && (this.y === otherPoint.y);
        };
    };

    return WebPDF.PDFPoint;
});